#include "test_common.h"
#include "FreeRTOS.h"
#include "task.h"
#include "usart.h"
#include "sys.h"

static uint32_t baseprio_get(void)
{
    uint32_t returnval;
    __asm{ mrs returnval, basepri }
    return returnval;
}

void vApplicationTickHook(void)
{
}

void test_critical_hook(void)
{
    uint32_t baseprio = 0, baseprio1 = 0;
    MLOGI("0, cur baseprio value:%d", baseprio_get());
    baseprio = taskENTER_CRITICAL_FROM_ISR();
    MLOGI("1, baseprio value:%d", baseprio);
    MLOGI("1, cur baseprio value:%d", baseprio_get());
    baseprio1 = taskENTER_CRITICAL_FROM_ISR();
    MLOGI("2, baseprio1 value:%d", baseprio1);
    MLOGI("2, cur baseprio value:%d", baseprio_get());
    taskEXIT_CRITICAL_FROM_ISR(baseprio1);
    MLOGI("3, cur baseprio value:%d", baseprio_get());
    taskEXIT_CRITICAL_FROM_ISR(baseprio);
    MLOGI("3, cur baseprio value:%d", baseprio_get());
}